<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<div id="page-content">
    <div class="row">

        <div class="col-lg-12">
            <div class="panel">
                <div class="panel-heading">
                    <h3 class="panel-title">资产明细</h3>
                </div>
                <div class="panel-body">
                    <div class="table-responsive">
                        <table id="asset_apply_table"></table>
                        <div id="asset_apply_page"></div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<script>

    $(function(){

        init_grid_asset();

    });

    function init_grid_asset() {

        __init_jqgrid('asset_apply_table', 'asset_apply_page',
                '<%=path%>/activiti/asset/list',
                ['固定资产编号', '资产名称', '品牌','规格型号','采购金额（元）', '使用人','资产状态', '操作', 'id'],
                [
                    {name: 'assetNo', index: 'assetNo', width: 80, sortable: true, search: false},
                    {name: 'name', index: 'name', width: 80, sortable: true, search: false},
                    {name: 'brand', index: 'brand', width: 80, sortable: false, search: false},
                    {name: 'model', index: 'model', width: 80, sortable: true, search: false},
                    {name: 'purchaseMoney', index: 'purchaseMoney', width: 80, sortable: false, search: false},
                    {name: 'userName', index: 'userName', width: 40, sortable: false, search: false},
                    {name: 'txtStatus', index: 'txtStatus', width: 40, sortable: false, search: false},
                    {name: 'act', index: 'act', width: 350, fixed: true, sortable: false, search: false, formatter: actFormat},
                    {name: 'id', index: 'id', width: 100, key: true, hidden: true, hidedlg: true}
                ],
                true,
                {
                    postData: {catalog: 0x02}
                }
        );

    }

    function actFormat(cellvalue, options, rowObject){
        var id = rowObject.id;
        cellvalue = '<button class="btn btn-white btn-sm" onclick="fn_asset_read(\'' + id + '\');"><i class="fa fa-eye"> </i> 查看</button>';
        if (rowObject.txtStatus=="使用中") {
            cellvalue += '<button class="btn btn-white btn-sm" onclick="fn_asset_flit(\'' + id + '\');"><i class="fa fa-share"> </i> 资产调拨</button>';
        }
        if (rowObject.txtStatus=="使用中" || rowObject.txtStatus=="空闲") {
            cellvalue += '<button class="btn btn-white btn-sm" onclick="fn_asset_maintain(\'' + id + '\');"><i class="fa fa-wrench"> </i> 资产维修</button>';
            cellvalue += '<button class="btn btn-white btn-sm" onclick="fn_asset_scrap(\'' + id + '\');"><i class="fa fa-trash-o"> </i> 资产报废</button>';
        }

        return cellvalue;
    }

    function fn_asset_read(id) {
        loadURL('<%=path%>/activiti/asset/read/'+id, $('#page-content'));
    }

    function fn_asset_flit(id) {
        loadURL('<%=path%>/activiti/asset/flit/'+id, $('#page-content'));
    }

    function fn_asset_maintain(id) {
        loadURL('<%=path%>/activiti/asset/maintain/'+id, $('#page-content'));
    }

    function fn_asset_scrap(id) {
        loadURL('<%=path%>/activiti/asset/scrap/'+id, $('#page-content'));
    }

</script>